import request from '@/utils/request'

/**
 *
 * @param {String|Number} channel_id 频道id
 * @param {Number} timestamp 时间戳,请求新的推荐数据需要传的时间
 * @returns promise
 */
export const getArticlesAPI = (channel_id, timestamp) =>
  request({
    url: '/v1_0/articles',
    params: {
      channel_id,
      timestamp
    }
  })
/**
 *  获取文章数据详细
 * @param {*} article_id 文章id
 * @returns promise
 */
export const getArticlesInfoAPI = (article_id) =>
  request({
    url: `/v1_0/articles/${article_id}`
  })
/**
 * 文章点赞
 * @param {*} article_id  文章id
 * @returns promise
 */
export const ArticlesLiveAPi = (article_id) =>
  request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: article_id
    }
  })
/**
 * 取消文章点赞
 * @param {*} article_id  文章id
 * @returns promise
 */
export const unArticlesLiveAPi = (article_id) =>
  request({
    url: `/v1_0/article/likings/${article_id}`,
    method: 'DELETE'
  })
/**
 * 收藏文章
 * @param {*} article_id  文章id
 * @returns promise
 */
export const collectArticlesAPI = (article_id) =>
  request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target: article_id
    }
  })
/**
 * 取消收藏文章
 * @param {*} article_id  文章id
 * @returns promise
 */
export const noCollectArticlesAPI = (article_id) =>
  request({
    url: `/v1_0/article/collections/${article_id}`,
    method: 'DELETE'
  })
